package logic

import (
	"context"
	"zhaowei/baidurpc/baidurpc"

	"zhaowei/api/internal/svc"
	"zhaowei/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerCetLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerCetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCetLogic {
	return &PerCetLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerCetLogic) PerCet(req *types.PerCetRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	per, err := l.svcCtx.BaiDuRpc.PerCet(l.ctx, &baidurpc.PerCetRequest{
		Username: req.Username,
		Mobile:   req.Mobile,
		Password: req.Password,
		SendSms:  req.SendSms,
		NickName: req.NickName,
		HeadImg:  req.HeadImg,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: "完善失败",
			Data:    nil,
		}, nil
	} else {
		return &types.Response{
			Code:    200,
			Message: "完善成功",
			Data:    per,
		}, nil
	}
	return
}
